Don't rely on Hash for Package deduplicating
authorAlex Crichton <alex@alexcrichton.com>
Fri, 12 Jun 2015 22:03:15 +0000 (15:03 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 12 Jun 2015 22:07:32 +0000 (15:07 -0700)
commit06a0605f7b93132870a4e2ec052059250c624131
treec614f0fc7888ab75b69d97a6dbaab6e8c3fa58c7
parentf98100f7776e358f215485db0a0330d2cb2df1da
Don't rely on Hash for Package deduplicating

The fix in #1697 was to alter the `Hash` implementation of `Package` to take
into account the source root instead of just the package id (so packages at the
same source would have the same hash). There's a spot, however, where we
normalize some paths and not others, causing two paths which logically point the
same location end up having different hashes, so the same package ended up being
stored multiple times, later leading to an assertion that there was only one
stored.

This commit alters the behavior of read_packages to keep a hash map of ID =>
Package instead of just a hash set of Package as the deduplication/equality
needs to be based on the ID, not the literal path to the source root.

This specific bug shows up when you have an override and a normal dependency
pointing at the same location (and the override has some inter-dependencies).
Not exactly a normal use case, but it showed up in Servo's build!
src/cargo/ops/cargo_read_manifest.rs
tests/test_cargo_compile_path_deps.rs